# #############################
# Build the waliparse library

import os,platform

Import('Debug')
Import('WaliDir')
Import('LibInstallDir')
Import('MkStatic')
Import('BaseEnv')
Import('XercesDir')

if Debug:
    print '\n+++ Entered "#/AddOns/Parse/Source/SConscript"\n'

waliparse_files = Split("""
./StrX.cpp
./wali/IUserHandler.cpp
./wali/IWaliHandler.cpp
./wali/Parser.cpp
./wali/QueryHandler.cpp
./wali/UserFactoryHandler.cpp
./wali/wfa/WfaHandler.cpp
./wali/wpds/WpdsHandler.cpp
./wali/wpds/ewpds/EWpdsHandler.cpp
""")

Env = BaseEnv.Clone()

# Define include directories
IncludeDirs = [
    os.path.join(WaliDir , 'Source'),
    os.path.join(WaliDir,'AddOns','Parse','Source'),
    os.path.join(WaliDir,'AddOns','Parse','ThirdParty',XercesDir,'include'),
]

Env['WARNING_FLAGS'] = Env['WARNING_FLAGS'].replace('-Wundef', '')
Env['WARNING_FLAGS'] = Env['WARNING_FLAGS'].replace('-Wshadow', '')

Env.Append(CPPPATH=[os.path.join(WaliDir,'AddOns','Parse','Source')])
Env.Append(CPPPATH=[os.path.join(WaliDir,'AddOns','Parse','ThirdParty',XercesDir,'include')])

if MkStatic:
    waliparse = Env.StaticLibrary('waliparse' , waliparse_files)
    i = Env.Install(LibInstallDir, waliparse)
    built = i
    Return('built')
else:
    waliparse = Env.SharedLibrary('waliparse' , waliparse_files,
                                  LIBS=['xerces-c', 'wali'],
                                  LIBPATH=LibInstallDir,
                                  RPATH=LibInstallDir,
                                  )
    i = Env.Install(LibInstallDir, waliparse)
    built = i
    Return('built')

